package com.tsmti.system.entity;


import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import com.tsmti.core.common.entity.BaseDataEntity;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import javax.persistence.Transient;

/**
 * @Package：com.tsmti.system.entity
 * @Class：User
 * @Description： 用户信息
 * @Author：zcw
 * @Date：Created in 2018/1/30 18:12
 * @Company:
 * @Version：
 * @Modified By:
 */
@Entity
@Table(name = "pims_user")
@DynamicUpdate
@DynamicInsert
@Where(clause = "delFlag = 0")
public class User extends BaseDataEntity<Long> {
    /**
     * 是否锁定（1：正常；-1：删除；0：锁定；）
     */
    public static final String STATUS_DELETE = "-1";
    public static final String STATUS_LOCKED = "0";
    public static final String STATUS_NORMAL = "1";

    /**
     * 用户Id
     */
    private Long id;

    /**
     * 用户名
     */
    private String userName;

    /**
     * 姓名
     */
    private String realName;

    /**
     * 头像
     */
    private String portrait;

    /**
     * 密码
     */
    private String password;

    /**
     * 盐
     */
    private String salt;

    /**
     * 邮件
     */
    private String email;

    /**
     * 联系电话
     */
    private String phone;

    /**
     * 所属部门ID，多个逗号分隔
     */
    private String departId;

    /**
     * 签名文件
     */
    private byte[] signature;

    /**
     * 系统用户的状态
     */
    private String status = STATUS_NORMAL;

    /**
     * HIS用户名
     */
    private String hisUserId;

    /**
     * LIS用户名
     */
    private String lisUserId;
    /**
     * 上级医生ID
     */
    private Long parentDoctorId;
    /**
     *人员类型（1医师2技师3医生4护士5其他）
     */
    private Integer userJobType;
    /**
     * 页面redis专用
     */
    private String code;
    /**
     *页面redis专用
     */
    private String name;

    @Transient
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
    @Transient
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_USER")
    @SequenceGenerator(name = "SEQ_USER", sequenceName = "user_sequence", allocationSize = 1)
    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getDepartId() {
        return departId;
    }

    public void setDepartId(String departId) {
        this.departId = departId;
    }

    public byte[] getSignature() {
        return signature;
    }

    public void setSignature(byte[] signature) {
        this.signature = signature;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getHisUserId() {
        return hisUserId;
    }

    public void setHisUserId(String hisUserId) {
        this.hisUserId = hisUserId;
    }

    public String getLisUserId() {
        return lisUserId;
    }

    public void setLisUserId(String lisUserId) {
        this.lisUserId = lisUserId;
    }

    @Transient
    public String getCredentialsSalt() {
        return userName + salt;
    }

    public Long getParentDoctorId() {
        return parentDoctorId;
    }

    public void setParentDoctorId(Long parentDoctorId) {
        this.parentDoctorId = parentDoctorId;
    }

    public Integer getUserJobType() {
        return userJobType;
    }

    public void setUserJobType(Integer userJobType) {
        this.userJobType = userJobType;
    }
}
